package com.erpanderp.wam.adm.view;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import org.primefaces.component.datatable.DataTable;

import com.erpanderp.wam.adm.model.entity.HolidayCalendar;
import com.erpanderp.wam.adm.model.service.HolidayCalendarDAO;


@ManagedBean
@ViewScoped
public class HolidayCalendarBean {
	
	private HolidayCalendar holidayCalendar = new HolidayCalendar();
	HolidayCalendarDAO holidayCalendarDAO = new HolidayCalendarDAO();
	private List<HolidayCalendar> holidaysList = new ArrayList<HolidayCalendar>();
	private DataTable assignedHolidays;
	private TimeZone defaultTimeZone = TimeZone.getDefault();
	public HolidayCalendarBean(){
		System.out.println("HOLIDAY CALENDAR IS LOADING");
		holidaysList = new HolidayCalendarDAO().getHolidays();
	}
	
	public void saveHoliday(){
		holidayCalendar.setCreateDate(new Date());
		holidayCalendar.setCreatedBy("Administrator");
		holidayCalendar.setStatus("ACTIVE");
		new HolidayCalendarDAO().createHolidayCalendar(holidayCalendar);
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO," Holiday created successfully.", ""));
	}
	
	
	public HolidayCalendar getHolidayCalendar() {
		return holidayCalendar;
	}
	public void setHolidayCalendar(HolidayCalendar holidayCalendar) {
		this.holidayCalendar = holidayCalendar;
	}

	

	public List<HolidayCalendar> getHolidaysList() {
		return holidaysList;
	}

	public void setHoliaysList(List<HolidayCalendar> holidaysList) {
		this.holidaysList = holidaysList;
	}

	public DataTable getAssignedHolidays() {
		return assignedHolidays;
	}

	public void setAssignedHolidays(DataTable assignedHolidays) {
		this.assignedHolidays = assignedHolidays;
	}

	public TimeZone getDefaultTimeZone() {
		return defaultTimeZone;
	}

	public void setDefaultTimeZone(TimeZone defaultTimeZone) {
		this.defaultTimeZone = defaultTimeZone;
	}

	

}
